Amber's Digital Garden

nginx Docker Setup

A simple setup for serving static files with nginx.


simple compose.yml:

services:
  nginx:
    image: nginx:latest
    restart: unless-stopped
    entrypoint: null
    volumes:
      - ./web:/usr/share/nginx/html
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      - ./logs:/var/log/nginx
    ports:
      - 8864:80
networks: {}

simple nginx.conf:

# Nginx configuration file for a static HTML server on port 80 (plain HTTP)
server {
  listen         80;
  server_tokens  off;
  server_name    mysite.org www.mysite.org;  # Customize the target subdomains
  error_log      /var/log/nginx/mysite.error.log warn;  # Customize the error log location

  root           /home/myuser/html;  # Customize the static files' location
  index          index.html;
  try_files $uri /index.html;
}

Sources:


by amber